package com.winning.pregnancyandroid.activities;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;

import com.example.pregnancyandroid.R;
import com.winning.pregnancyandroid.utils.HTTPGetTool;
import com.winning.pregnancyandroid.utils.URLUtils;
import com.alibaba.fastjson.JSON;
import android.os.Bundle;
import android.os.StrictMode;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.GridView;

public class Regsiter extends Activity {
	private EditText phonenum,nickname,pretime,password,confpassword,authcode;
	private Button getauthcode,confirmbtn;
	@SuppressLint("NewApi")  
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()       
        .detectDiskReads()       
        .detectDiskWrites()       
        .detectNetwork()   // or .detectAll() for all detectable problems       
        .penaltyLog()       
        .build());       
		StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder()       
        .detectLeakedSqlLiteObjects()    
        .penaltyLog()       
        .penaltyDeath()       
        .build());  
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);// 去掉标题栏
		setContentView(R.layout.regsiter);

		findViews(); //初始化样式
		initData();//初始化数据

		setListener();
		
	}

	public  void findViews(){
		phonenum = (EditText) findViewById(R.id.phone);
		nickname = (EditText) findViewById(R.id.nickname);
		pretime = (EditText) findViewById(R.id.pregnancytime);
		password = (EditText) findViewById(R.id.password);
		confpassword = (EditText) findViewById(R.id.confirmpassword);
		authcode = (EditText) findViewById(R.id.authcode);
		confirmbtn = (Button) findViewById(R.id.confirmbtn);
		getauthcode = (Button) findViewById(R.id.getauthcode);
		
	}
	
	public void initData(){
		
	}
	
	
	private void setListener(){
		getauthcode.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				String sjh = phonenum.getText().toString().trim();
				Map<String, String> map = new HashMap<String, String>();
				List<NameValuePair> params = new ArrayList<NameValuePair>();
				map.put("sjh", sjh);
				params.add(new BasicNameValuePair("jsReq", JSON.toJSONString(map)));
				JSONObject json = HTTPGetTool.getTool().post(URLUtils.HOSTMAIN+URLUtils.URLSAVEMESSAGE, params);
				
			}
		});
	}

}
